<template>
    <div>
        <div class="title">
            <div style="float: left">欢迎使用冀商传奇管理平台</div>
            <div style="float: right">
                <img src="../assets/indexVue/phone.png" style="display: inline">
                <span>{{phoneNum}}</span>
            </div>
        </div>
        <div class="indexContainer">
            <div class="list">
                <div v-for="item in list" :key="item.id" class="box">
                    <div class="outer">
                        <img :src="item.imgHref">
                    </div>
                    <p class="listTitle" v-text="item.title"></p>
                    <p class="listNum" v-text="item.count"></p>
                </div>
            </div>
            <div class="quickOperation">
                <div>快捷操作</div>
                <div class="action">
                    <div v-for="item in application" :key="item.id" class="appBox" @click="changeRouter(item.title)">
                        <div class="appOuter">
                            <img :src="item.imgHref">
                        </div>
                        <p class="appTitle" v-text="item.title"></p>
                        <p class="appNum" v-text="item.count"></p>
                    </div>
                </div>
            </div>
        </div>
        <div class="article">
            <div v-for="item in article" :key="item.id" class="artBox">
                <div class="artTop">
                    <img :src="item.imgHref">
                    <span class="artTitle" v-text="item.title"></span>
                </div>
                <div class="artNum" v-text="item.count"></div>
            </div>
        </div>
        <footer>
            <img src="@/assets/images/login-background.jpg">
        </footer>
    </div>

</template>
<script setup name="Index" lang="ts">
import  {indexList,getApplication, getArticle} from "@/api/indexVue";
import {getInfo} from "@/api/login";
import {ref} from "vue";
import router from "@/router";
let phoneNum = ref<string>('');
let list = ref<object[]>();
let imgList = ref<string[]>(['http://192.168.5.120:14444/static/img/js_bonus_l.b10342f9.png', '', '', 'http://192.168.5.120:14444/static/img/apply_l.985fb2da.png']);
let application= ref<object[]>();
let imgApp=ref<string[]>(['',''])
let article=ref<object[]>();
let imgArt=ref<string[]>(['','','','',''])
indexList().then(res => {
    list.value = (res as any).rows;
    let i = 0;
    list.value?.forEach(item => {
        (item as any).imgHref = imgList.value[i];
        (item as any).id = i;
        console.log(item);
        i++;
    });

});
getInfo().then(res => {
    phoneNum.value = (res as any).user.phonenumber;
});
getApplication().then(res=>{
    application.value=(res as any).rows;
    let i = 0;
    application.value?.forEach(item => {
        (item as any).imgHref = imgApp.value[i];
        (item as any).id = i;
        i++;
    });
});
getArticle().then(res=>{
    article.value=(res as any).rows;
    let i = 0;
    article.value?.forEach(item => {
        (item as any).imgHref = imgArt.value[i];
        (item as any).id = i;
        i++;
    });
});
function  changeRouter(title:string) :void{
    if(title==='新增申请'){
        router.push('/system/apply');
    }else if(title==='新增业务'){
        router.push('/system/post-review');
    }

}
</script>

<style scoped lang="scss">
img{
    display: inline;
}
.title{
    height: 65px;
    border-bottom: 1px solid rgb(237, 237, 237);
    line-height: 65px;
    padding: 0 40px;
    overflow: hidden;
}
.indexContainer{
    display: flex;
    justify-content: space-between;
    padding: 20px;
}
.list{
    display: flex;
    justify-content: space-between;
    width: 60%;
}
.quickOperation{
    padding: 15px;
    width: 38%;
    border: 1px solid #f1f0f9;
    border-radius: 10px;
    -webkit-box-shadow: 3px 3px #f6f6f6;
    box-shadow: 3px 3px #f6f6f6;
}
.box{
    border: 1px solid #f1f0f9;
    border-radius: 10px;
    text-align: center;
    padding: 15px 20px;
    width: 22%;
    -webkit-box-shadow: 3px 3px #f6f6f6;
    box-shadow: 3px 3px #f6f6f6;
    height: 220px;
}
.outer{
    border-radius: 10px;
    padding: 15px;
    -webkit-box-shadow: 5px 5px #f6f6f6;
    box-shadow: 5px 5px #f6f6f6;
}
.outer img{
    overflow-clip-margin: content-box;
    overflow: clip;
}
.listTitle{
    margin: 10px 0;
    color: #adaaca;
    font-size: 14px;
    font-weight: 700;
}
.listNum{
    font-size: 20px;
    color: #adaaca;
    margin: 0;
}
.action{
    margin-top: 10px;
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -ms-flex-pack: distribute;
    justify-content: space-around;
    text-align: center;
    margin-left: 50px;
    cursor: pointer;
}
.appOuter{
    padding: 20px;
    &:hover{
        background-color: rgb(235, 249, 255);
    }
    border-radius: 10px;
}
.appOuter img{
    overflow-clip-margin: content-box;
    overflow: clip;
}
.appTitle{
    margin: 10px 0;
    color: #adaaca;
    font-size: 14px;
    font-weight: 700;
}
.appNum{
    font-size: 20px;
    color: #adaaca;
    margin: 0;
}
.article{
    padding: 10px 20px;
    text-align: center;
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -ms-flex-pack: distribute;
    justify-content: space-between;

}
.artBox{
    width: 23%;
    -webkit-box-shadow: 5px 5px #f6f6f6;
    box-shadow: 5px 5px #f6f6f6;
    border-radius: 15px;
    padding: 20px;
}
.artBox img{
    overflow-clip-margin: content-box;
    overflow: clip;
    vertical-align: top;
    margin-right: 5px;
}
.artTitle{
    font-size: 18px;
    font-weight: 700;
    margin-top: 15px;

}
.artNum{
    font-size: 18px;
    font-weight: 700;
    margin-top: 15px;

}
footer{
    padding: 10px 20px 0;
    width: 100%;
    height: calc(100vh - 556px);
}
footer img{
    width: 100%;
    height: 100%;
    border-radius: 5px;
    -webkit-box-shadow: 2px 2px #f7f8fa;
    box-shadow: 2px 2px #f7f8fa;
}
</style>
